package com.feng.annotation.controller;

import com.feng.annotation.bean.User;
import com.feng.annotation.service.UserService;
import com.feng.annotation.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Random;
import java.util.UUID;

/**
 * @author Lee
 * @date 2019/3/9
 */
@RequestMapping("/user")
@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/saveUser")
    @ResponseBody
    public ResponseResult saveUser(){
        User user = new User();
        user.setUsername(UUID.randomUUID().toString().substring(20));
        user.setAge(new Random(100).nextInt());
        try {
//            userService.saveUser(user);
        } catch (Exception e) {
            return ResponseResult.failNoDataAndMessage();
        }
        return ResponseResult.successNoDataAndMessage();
    }

}
